package com.sky.controller.user;


import com.sky.constant.StatusConstant;
import com.sky.dto.CategoryDTO;
import com.sky.entity.Category;
import com.sky.service.CategoryService;
import com.sky.web.controller.BaseController;
import com.sky.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@Slf4j
@Api(tags = "微信端分类接口")
@RestController("userCategoryController")
@RequestMapping("/user/category")
public class CategoryController extends BaseController {

    @Autowired
    private CategoryService categoryService;

    /**
     * 查询分类
     * @param dto
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("查询分类")
    @Cacheable(cacheNames = "categoryCache")
    public AjaxResult list(CategoryDTO dto) {
        dto.setStatus(StatusConstant.ENABLE);
        List<Category> list = categoryService.selectCategoryListByType(dto);
        return AjaxResult.success(list);
    }
}
